package org.springframework.boot.autoconfigure.validation;

import org.springframework.context.annotation.Configuration;
import top.malaoshi.easy.logging.Log;
import top.malaoshi.easy.logging.LogFactory;
import top.malaoshi.webmvc.ScanClassHandler;
import top.malaoshi.webmvc.ThymeleafResponseHandler;

/**
 * Thymeleaf自动配置器，当存在 org.thymeleaf.TemplateEngine 类时，就执行
 */
@Configuration
public class HibernateValidatorAutoConfiguration {

    static final Log LOG = LogFactory.getLog(HibernateValidatorAutoConfiguration.class);
    static{
        try {
            // 如果有此类，就说明已经添加相应注解，初始化
            Class.forName("org.hibernate.validator.messageinterpolation.ParameterMessageInterpolator");
            LOG.debug("启用 hibernate validator");
            HibernateValidatorUtil.init();
            ScanClassHandler.me().addClass(ValidatorImpl.class);
        } catch (ClassNotFoundException e) {
        }
    }

}
